﻿#VisualFreeBasic_Form#  Version=5.9.7
Locked=0

[Form]
Name=Form2
Help=False
ClassStyle=CS_VREDRAW,CS_HREDRAW,CS_DBLCLKS
ClassName=
WinStyle=WS_THICKFRAME,WS_CAPTION,WS_SYSMENU,WS_MINIMIZEBOX,WS_MAXIMIZEBOX,WS_CLIPSIBLINGS,WS_CLIPCHILDREN,WS_VISIBLE,WS_EX_WINDOWEDGE,WS_EX_CONTROLPARENT,WS_EX_LEFT,WS_EX_LTRREADING,WS_EX_RIGHTSCROLLBAR,WS_POPUP,WS_SIZEBOX
Style=3 - 常规窗口
Icon=
Caption=图标预览
StartPosition=2 - 父窗口中心
WindowState=0 - 正常
Enabled=True
Repeat=False
Left=0
Top=0
Width=804
Height=680
TopMost=False
Child=False
MdiChild=False
TitleBar=True
SizeBox=True
SysMenu=True
MaximizeBox=True
MinimizeBox=True
Help=False
Hscroll=False
Vscroll=False
MinWidth=400
MinHeight=300
MaxWidth=0
MaxHeight=0
NoActivate=False
MousePass=False
TransPer=0
TransColor=SYS,25
Shadow=0 - 无阴影
BackColor=SYS,15
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[YFList]
Name=YFList1
Help=
Index=-1
Enabled=True
Visible=True
ForeColor=&H000000
BackColor=&HFFFFFF
MoveColor=&HFFE5CC
SelFore=&HFFFFFF
SelBack=&HE57300
ScrollFore=&H878787
ScrollBack=&HE1E1E1
ScrollMove=&H4B4B4B
LinesColor=&HA5A5A5
FrameColor=RGB(90,90,90)
FocusColor=RGB(0,0,255)
ItemHeight=150
Check=False
GridLines=True
Font=微软雅黑,9
Left=5
Top=5
Width=179
Height=600
Layout=4 - 调整高度
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[Picture]
Name=Picture1
Help=
Index=-1
Style=1 - 细边框
Enabled=True
Visible=True
Left=190
Top=5
Width=566
Height=601
Layout=5 - 宽度和高度
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[VScroll]
Name=VScroll1
Help=
Index=-1
Max=9999
Min=0
Value=0
Page=0
SmallChange=1
LargeChange=10
Enabled=True
Visible=True
Left=760
Top=10
Width=21
ALING=False
Height=601
Layout=6 - 右边和高度
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False
AcceptFiles=False

[YFtext]
Name=YFtext2
Help=
Index=-1
Presets=0 - 控件预设选择
Text=
TipText=这里可以直接输入vico字符，立即生效
LText=VICO字符：
RText=复制
LvIco=
RvIco=
Enabled=True
Visible=True
MaxLength=0
PasswordChar=
Locked=False
HideSelection=True
Number=False
Frame=True
UpDown=False
UpMax=100
UpMin=0
LSpace=60
RSpace=50
ZColor=RGB(0,0,0)
TColor=RGB(180,180,180)
LColor=RGB(0,115,229)
RColor=RGB(0,204,0)
DColor=SYS,15
ZDColor=RGB(255,255,255)
kColor=RGB(105,105,105)
jColor=RGB(0,85,255)
Font=微软雅黑,9,0
Left=5
Top=610
Width=784
Height=29
Layout=8 - 底部和宽度
MousePointer=0 - 默认
Tag=
Tab=True
ToolTip=
ToolTipBalloon=False


[AllCode]
Dim Shared 鼠标移动 As Long ,鼠标按下 As Long

'[Form2.Picture1]事件 : 重绘，系统通知控件需要重新绘画。
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Function Form2_Picture1_WM_Paint(hWndForm As hWnd, hWndControl As hWnd) As LResult
   Dim tt As ULong =GetTickCount
   
   Dim gg As yGDI = yGDI(hWndControl, GetSysColor(COLOR_WINDOW), True) 'WM_PAINT事件里必须用这行初始化 yGDI
   Dim As Long x, y, v, ww = DpiUnScaleI(gg.m_Width), hh = DpiUnScaleI(gg.m_Height)
   
   Dim kw As Long = 60, zz As Long
   Dim As Long jw = Int(ww / kw), jh = Int(hh / (kw + 10)), tx, ty
   Dim u As Long = UBound(t图标列表)
   If u = -1 Then Return True
   Dim m As Long = VScroll1.nMax, mm As Long = Int(u / jw) -2
   If m <> mm Then VScroll1.nMax = mm
   v = VScroll1.Value
   Picture1.UserData(0) = jw
   Picture1.UserData(1) = jh
   Picture1.UserData(3) = v
   gg.Brush
   gg.Pen 1, &HE1E1E1 'GDI的颜色值。RGB=225,225,225
   gg.SetColor 0
   gg.Font
   Dim VIco As String, 名称 As String,f As Long 
   For y = 0 To jh -1
      For x = 0 To jw -1
         zz = y * jw + x + v * jw
         If zz < 0 Or zz > u Then Exit For, For
         tx = x * kw
         ty = y * (kw + 10)
         If 鼠标移动 = zz + 1 Then
            gg.Pen 1, IIf(鼠标按下, &HFF00FF, 0)
         End If
         VIco = t图标列表(zz)
         If Left(VIco, 1) = "{" Then
            f = InStr(2, VIco, "}")
            If f = 0 Then f = Len(VIco) + 1
            名称 = Mid(VIco, 2, f -2)
            VIco=Mid(VIco,f+1)
            f  += 1
         Else
            名称 = ""
         End If
         gg.DrawFrame tx, ty, kw, kw -5
         gg.GpDrawVectorIcon(tx+kw*0.2, ty+kw*0.16, kw*0.6, kw*0.6 ,VIco) 
         
         gg.DrawFrame tx, ty + 55, kw, 15
         gg.DrawTextS(tx, ty + 55, kw, 15, WStr(zz+1), DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOPREFIX)
         
         If 鼠标移动 = zz + 1 Then
            gg.Pen 1, &HE1E1E1 'GDI的颜色值。RGB=225,225,225
         End If
      Next
   Next
  Me.Caption ="图标预览：绘图耗时 " &  GetTickCount -tt  & " 毫秒"
   
   Function = TRUE ' 告诉系统，我们自绘了，不需要系统绘画。
End Function

'[Form2.VScroll1]事件 : 上下滚动条的值发生了改变
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'nScrollCode = SB_LINEUP    SB_LINEDOWN   SB_PAGEUP    SB_PAGEDOWN   SB_THUMBPOSITION SB_THUMBTRACK  SB_ENDSCROLL   SB_TOP      SB_BOTTOM  
''             点击向上按钮 点击向下按钮  点击滑块上面 点击滑块下面  托动滑块结束     托动滑块进行中 结束滚动条操作 滚动到顶部  滚动到底部  
'vNewPos       滑块位置（注意：因为操作系统传来是16位数，最大为65535）
Sub Form2_VScroll1_Change(hWndForm As hWnd, hWndControl As hWnd, vNewPos As Long, nScrollCode As Long )
 Picture1.Refresh 

End Sub
Function 获取鼠标位置2(xPos As Long ,yPos As Long) As Long
   xPos = DpiUnScaleI(xPos)
   yPos = DpiUnScaleI(yPos)
   Dim jw As Long = Picture1.UserData(0)
   Dim jh As Long = Picture1.UserData(1)
   Dim v  As Long = Picture1.UserData(3)
   Dim As Long x ,y ,tx ,ty ,u = UBound(t图标列表)
   Dim kw As Long = 60 ,zz As Long
   '排除超过范围的
   If xPos >= jw *kw         Then Return 0
   If yPos >= jh * (kw + 10) Then Return 0
   x  = Int(xPos / kw)
   y  = Int(yPos / (kw + 10))
   zz = (y + v) * jw + x 
   If zz < 0 Or zz > u Then Return 0
   Function = zz + 1
End Function
'[Form2.Picture1]事件 : 按下鼠标左键
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。
Sub Form2_Picture1_WM_LButtonDown(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim aa As Long = 获取鼠标位置2(xPos, yPos)
   Dim bb As Long = -1
   If aa <> 鼠标移动 Or bb <> 鼠标按下 Then
      鼠标移动 = aa
      鼠标按下 = bb
      If aa > 0 And aa -1 <= UBound(t图标列表) Then
         aa -= 1
         Dim i As Long
         bb = 0
         For i = 0 To YFList1.ListCount -1
            If YFList1.ItemData(i) = aa Then
               bb = i + 1
               exit for
            End If
         Next
         If bb = 0 Then
            YFList1.ListIndex = YFList1.AddItem("", 0, aa)
         Else
            YFList1.ListIndex = bb -1
         End If
         i = InStr(t图标列表(aa), "}")
         YFtext2.Text = Utf8toStringW(Mid(t图标列表(aa), i + 1))
         
      End If
      Picture1.Refresh
   End If
   
   
End Sub

'[Form2.Picture1]事件 : 释放鼠标左键
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。
Sub Form2_Picture1_WM_LButtonUp(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim aa As Long = 获取鼠标位置2(xPos ,yPos)
   Dim bb As Long = 0
   If aa <> 鼠标移动 Or bb <> 鼠标按下 Then
      鼠标移动 = aa
      鼠标按下 = bb
      Picture1.Refresh
   End If

End Sub

'[Form2.Picture1]事件 : 移动鼠标
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。
Sub Form2_Picture1_WM_MouseMove(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim aa As Long = 获取鼠标位置2(xPos ,yPos)
   Dim bb As Long = MouseFlags <> 0
   If aa <> 鼠标移动 Or bb <> 鼠标按下 Then
      鼠标移动 = aa
      鼠标按下 = bb
      Picture1.Refresh
   End If

End Sub

'[Form2.Picture1]事件 : 旋转鼠标滚轮
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'WheelDelta 为旋转的距离，以倍数或分度表示，通常为120（具体看WIN系统设置），正值 120 表示向前旋转，负值 -120 表示向后旋转  
'xPos yPos   当前鼠标位置，相对于屏幕左上角的坐标。
Sub Form2_Picture1_WM_MouseWheel(hWndForm As hWnd, hWndControl As hWnd, WheelDelta As Long, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim vv As Long = WheelDelta / 120
   VScroll1.Value = VScroll1.Value - vv
   鼠标移动       = 0
   鼠标按下       = 0
   Picture1.Refresh
   
End Sub

'[Form2.Picture1]事件 : 鼠标离开控件
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form2_Picture1_WM_MouseLeave(hWndForm As hWnd, hWndControl As hWnd)
   鼠标移动 = 0
   Picture1.Refresh

End Sub

'[Form2.YFList1]事件 : 列表项目选择已经改变
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'newIndex    新的索引 (从零开始)
Sub Form2_YFList1_SelChange(hWndForm As hWnd, hWndControl As hWnd, newIndex As Long)
   Dim i As Long = YFList1.ListIndex 
   If i=-1 Then Return 
   Dim f As Long =InStr(t图标列表(YFList1.ItemData(i)),"}")
    YFtext2.Text = Utf8toStringW(Mid(t图标列表(YFList1.ItemData(i)),f+1))

End Sub

'[Form2.YFList1]事件 : 自绘控件
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'StartY      最初开始显示位置，以实际像素为单位，就是索引0 项目显示的位置 计算第一个显示项目=Int(-StartY / 行高)
'ItemHeight  行高，100%DPI数值，实际使用时=DpiScaleI(ItemHeight)  来支持高DPI
'sumU        项目总数量，循环时用 For i=0 To sumU-1
'nList       项目数组指针，使用时是 nList[i]  
'selIndex    当前被选择项目
'kMouse      鼠标在什么项目上，从0开始的索引，=-1 表示没在
'kPress      鼠标是不是按下
Function Form2_YFList1_OwnerDraw(hWndForm As hWnd,hWndControl As hWnd,StartY As Long,ItemHeight As Long ,sumU As Long,nList As YFListData Ptr,selIndex As Long,kMouse As Long,kPress As Long) As LResult
   Dim 窗口色       As ULong = BGR(255, 255, 255)
   Dim 窗口字       As ULong = &H000000
   Dim 窗口亮度色10 As Long  = BGR(229, 255, 229)
   Dim 窗口亮度色20 As Long  = BGR(242, 229, 255)
   Dim 窗口亮度色40 As Long  = BGR(153, 204, 255)
   
   
   Dim gg  As yGDI   = yGDI(hWndControl, 窗口色, True) 'WM_PAINT事件里必须用这行初始化 yGDI
   Dim dpi As Single = gg.Dpi
   Dim ww  As Long   = gg.m_Width, hh As Long = gg.m_Height
   Dim ah  As Long   = DpiScaleI(ItemHeight) '行高
   Dim ai  As Long '列表框中第一个可见项目
   If sumU * ah > hh Then ww -= 10 *dpi '有滚动条时
   Dim x As Long
   gg.SetColor 窗口字
   ai = Int( - StartY / ah)
   dim y As Long = StartY + ai *ah
   gg.dpi = 1
   Dim As Long ci, i, tx, ty, tw, th
   'gg.Pen 0 ,0
   gg.Pen 1, 窗口亮度色10
   Dim VIco As String, 名称 As String,f As Long    
   For i = ai To sumU -1
      gg.Pen 0, 0
      If selIndex = i Then
         gg.Brush 窗口亮度色40
         gg.DrawFrame 0, y, ww, ah
      Else
         If kMouse = i Then
            gg.Brush IIf(kPress, 窗口亮度色20, 窗口亮度色10)
            gg.DrawFrame 0, y, ww, ah
         End If
      End If
      gg.Pen 1, &HC3C3C3
      gg.Brush -1 ' &HFFFFFF
      tx = x + (ww - (ah -25 *dpi)) / 2
      ty = y + 5 *dpi
      tw = ah -25 *dpi
          VIco = t图标列表(nList[i].DataValue)
         If Left(VIco, 1) = "{" Then
            f = InStr(2, VIco, "}")
            If f = 0 Then f = Len(VIco) + 1
            名称 = Mid(VIco, 2, f -2)
            VIco=Mid(VIco,f+1)
            f  += 1
         Else
            名称 = ""
         End If     
      gg.DrawFrame tx, ty, tw, tw
      gg.GpDrawVectorIcon( tx, ty, tw, tw,Utf8toStr(VIco))  
      gg.Font, 9 *dpi
      gg.DrawTextS(x, y + ah -20 *dpi, ww, 20 *dpi,  WStr(nList[i].DataValue + 1) & "." & Utf8toStr(名称) , DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOPREFIX Or DT_WORD_ELLIPSIS)
      
      y += ah
      gg.Pen 1, BGR(165, 165, 165)
      gg.DrawLine x, y -1, ww, y -1
      If y > hh Then Exit For
   Next
   gg.Pen 1, BGR(0, 0, 0)
   gg.Brush
   gg.DrawFrame 0, 0

   Function = FALSE ' 自己画了后需要应返回 TRUE 控件就不画了，不然控件会再画。

End Function

'[Form2.YFList1]事件 : 双击鼠标左键
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
Sub Form2_YFList1_WM_LButtonDblclk(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   Dim i As Long = YFList1.ListIndex 
   If i>-1 Then YFList1.RemoveItem i 

End Sub

'[Form2.YFtext2]事件 : 文本已经被修改（修改前用 EN_UPDATE
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
Sub Form2_YFtext2_EN_Change(hWndForm As hWnd, hWndControl As hWnd)


End Sub

'[Form2.YFtext2]事件 : 左边标签鼠标按下
'hWndForm    当前窗口的句柄(WIN系统用来识别窗口的一个编号，如果多开本窗口，必须 Me.hWndForm = hWndForm 后才可以执行后续操作本窗口的代码)
'hWndControl 当前控件的句柄(也是窗口句柄，如果多开本窗口，必须 Me.控件名.hWndForm = hWndForm 后才可以执行后续操作本控件的代码 )
'MouseFlags  MK_CONTROL   MK_LBUTTON     MK_MBUTTON     MK_RBUTTON    MK_SHIFT     MK_XBUTTON1       MK_XBUTTON2 
''           CTRL键按下   鼠标左键按下   鼠标中键按下   鼠标右键按下  SHIFT键按下  第一个X按钮按下   第二个X按钮按下
'检查什么键按下用  If (MouseFlags And MK_CONTROL)<>0 Then CTRL键按下 
'xPos yPos   当前鼠标位置，相对于控件。就是在控件里的坐标。 
Sub Form2_YFtext2_Right_LButtonDown(hWndForm As hWnd, hWndControl As hWnd, MouseFlags As Long, xPos As Long, yPos As Long)
   AfxSetClipboardText(YFtext2.Text)
   
End Sub














